<script type="text/javascript">
var editor = null;
var editorname = null;
KindEditor.options.filterMode = false;
KindEditor.ready(function(K) {
    var editor<?=$args['textareaid']?> = K.create('#<?=$args['textareaid']?>', {
        cssPath : '<?=WEBURL ?>/editor/plugins/code/prettify.css',
        uploadJson : '<?=WEBURL ?>/editor/upload_json.php',
        fileManagerJson : '<?=WEBURL ?>/editor/file_manager_json.php',
        allowFileManager : true,
        designMode:true,
		show:'block',
		afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form')[0].submit();
					});
				}
    });
	editor = K;
	editorname = editor<?=$args['textareaid']?>;
    <? if($args['uploadbutton']){?>
    K('#<?=$args['uploadbutton']?>').click(function () {
            editor<?=$args['textareaid']?>.loadPlugin('image', function () {
                editor<?=$args['textareaid']?>.plugin.imageDialog({
                    imageUrl: K('#<?=$args['inputid']?>').val(),
                    clickFn: function (url, title, width, height, border, align) {
                        K('#<?=$args['inputid']?>').val(url);
                        editor<?=$args['textareaid']?>.hideDialog();
                    }
                });
            });
        });
		<? } if(isset($args['uploadbutton1'])){?>
		K('#<?=$args['uploadbutton1']?>').click(function () {
				editor<?=$args['textareaid']?>.loadPlugin('image', function () {
					editor<?=$args['textareaid']?>.plugin.imageDialog({
						imageUrl: K('#<?=$args['inputid1']?>').val(),
						clickFn: function (url, title, width, height, border, align) {
							K('#<?=$args['inputid1']?>').val(url);
							editor<?=$args['textareaid']?>.hideDialog();
						}
					});
				});
			});	
	<? } if(isset($args['uploadbutton2'])){?>
    K('#<?=$args['uploadbutton2']?>').click(function () {
            editor<?=$args['textareaid']?>.loadPlugin('image', function () {
                editor<?=$args['textareaid']?>.plugin.imageDialog({
                    imageUrl: K('#<?=$args['inputid2']?>').val(),
                    clickFn: function (url, title, width, height, border, align) {
                        K('#<?=$args['inputid2']?>').val(url);
                        editor<?=$args['textareaid']?>.hideDialog();
                    }
                });
            });
        });	
	<? } ?>
    prettyPrint();
	
});
//chorme,firefox  
var event = document.createEvent('HTMLEvents');   
event.initEvent("load", true, true);     
window.dispatchEvent(event);     
//ie  
if(document.createEventObject){  
var event = document.createEventObject();  
 window.fireEvent('onload', event);  
} 
</script>
